#include"Engine.h"

namespace Advanced2D{
	Input::Input(HWND window){
		DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&di, NULL);

		di->CreateDevice( GUID_SysKeyboard, &keyboard, NULL);
		keyboard->SetDataFormat(&c_dfDIKeyboard);
		keyboard->SetCooperativeLevel(window, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);
		keyboard->Acquire();

	}

	Input::~Input(){
		if(di) di->Release();
		if(keyboard) keyboard->Release();
	}

	void Input::Update(){
		keyboard->Poll();
		if(!SUCCEEDED(keyboard->GetDeviceState(256, (LPVOID) &keyState))){
			keyboard->Acquire();
		}
	}
}